****What follows are the Stata commands necessary to produce the tables in the supplementary appendix. Before running the commands, convert all datasets into Stata format, or otherwise infile them at the relevant command. Also include the relevant file path information for each dataset.

****to produce Table A1
use "votes.dta"
merge m:1 congress state_icpsr using "populations.dta"
drop _merge
gen yesvote = cast_code
recode yesvote (1=1) (6=0) (else=.)
gen novote=cast_code
recode novote (6=1) (1=0) (else=.)
gen yespop= (yesvote * population)/2
gen nopop= (novote * population)/2
collapse (sum) yesvote novote yespop nopop, by(congress rollnumber)
gen cmy=0
replace cmy=1 if (yesvote > novote) & (yespop<nopop)
gen cmn=0
replace cmn=1 if (novote >=yesvote) & (yespop>nopop)
gen cmy01=0
replace cmy01=1 if (yesvote > novote) & (yespop< nopop) & abs((yespop-nopop)/(yespop+nopop)) > .01
gen cmy03=0
replace cmy03=1 if (yesvote > novote) & (yespop< nopop) & abs((yespop-nopop)/(yespop+nopop)) > .03
gen cmy05=0
replace cmy05=1 if (yesvote > novote) & (yespop< nopop) & abs((yespop-nopop)/(yespop+nopop)) > .05
gen cmy10=0
replace cmy10=1 if (yesvote > novote) & (yespop< nopop) & abs((yespop-nopop)/(yespop+nopop)) > .1
gen cmn01=0
replace cmn01=1 if (novote >=yesvote) & (yespop>nopop) & abs((yespop-nopop)/(yespop+nopop)) > .01
gen cmn03=0
replace cmn03=1 if (novote >=yesvote) & (yespop>nopop) & abs((yespop-nopop)/(yespop+nopop)) > .03
gen cmn05=0
replace cmn05=1 if (novote >=yesvote) & (yespop>nopop) & abs((yespop-nopop)/(yespop+nopop)) > .05
gen cmn10=0
replace cmn10=1 if (novote >=yesvote) & (yespop>nopop) & abs((yespop-nopop)/(yespop+nopop)) > .1
gen cm = cmy+cmn
gen cm01 = cmy01+cmn01
gen cm03 = cmy03+cmn03
gen cm05 = cmy05+cmn05
gen cm10 = cmy10 + cmn10
collapse (mean) cm cm01 cm03 cm05 cm10, by(congress)
merge 1:1 congress using "independent_vars.dta"
drop _merge
sort congress
tset congress
generate newcm=d.cm
generate newcm01=d.cm01
generate newcm03=d.cm03
generate newcm05=d.cm05
generate newcm10=d.cm10
generate newgini=d.gini
generate newclosevote=d.closevote
generate newmajfrac=d.majfrac
regress newcm newgini newclosevote newmajfrac
outreg2 using test.doc, dec(2)
regress newcm01 newgini newclosevote newmajfrac
outreg2 using test.doc, dec(2) append
regress newcm03 newgini newclosevote newmajfrac
outreg2 using test.doc, dec(2) append
regress newcm05 newgini newclosevote newmajfrac
outreg2 using test.doc, dec(2) append
regress newcm10 newgini newclosevote newmajfrac
outreg2 using test.doc, dec(2) append
clear

****to produce Table A2
use "votes.dta"
merge m:1 congress state_icpsr using "populations.dta"
drop _merge
gen yesvote = cast_code
recode yesvote (1=1) (6=0) (else=.)
gen novote=cast_code
recode novote (6=1) (1=0) (else=.)
gen yespop= (yesvote * population)/2
gen nopop= (novote * population)/2
collapse (sum) yesvote novote yespop nopop, by(congress rollnumber)
gen cmy=0
replace cmy=1 if (yesvote > novote) & (yespop< nopop)
gen cmn=0
replace cmn=1 if (novote >=yesvote) & (yespop>nopop)
gen cm = cmy+cmn
collapse (mean) cm, by(congress)
merge 1:1 congress using "independent_vars.dta"
drop _merge
betareg cm gini closevote majfrac
outreg2 using test.doc,dec(2)
clear

****to produce Table A3
use "votes.dta"
merge m:1 congress state_icpsr using "populations.dta"
drop _merge
gen yesvote = cast_code
recode yesvote (1=1) (6=0) (else=.)
gen novote=cast_code
recode novote (6=1) (1=0) (else=.)
gen yespop= (yesvote * population)/2
gen nopop= (novote * population)/2
collapse (sum) yesvote novote yespop nopop, by(congress rollnumber)
gen cmy=0
replace cmy=1 if (yesvote > novote) & (yespop< nopop)
gen cmn=0
replace cmn=1 if (novote >=yesvote) & (yespop>nopop)
gen cm = cmy+cmn
keep if abs((yesvote-novote)/(yesvote+novote)) < .2
collapse (mean) cm, by(congress)
merge 1:1 congress using "independent_vars.dta"
drop _merge
sort congress
tset congress 
generate newcm=d.cm
generate newgini=d.gini
generate newclosevote=d.closevote
generate newmajfrac=d.majfrac
regress newcm newgini
outreg2 using test.doc,dec(2)
regress newcm newmajfrac
outreg2 using test.doc, dec(2) append
regress newcm newgini newmajfrac
outreg2 using test.doc, dec(2) append
clear

****to produce Table A4
use "votes.dta"
merge m:1 congress state_icpsr using "populations.dta"
drop _merge
gen yesvote = cast_code
recode yesvote (1=1) (6=0) (else=.)
gen novote=cast_code
recode novote (6=1) (1=0) (else=.)
gen yespop= (yesvote * population)/2
gen nopop= (novote * population)/2
collapse (sum) yesvote novote yespop nopop, by(congress rollnumber)
gen cmy=0
replace cmy=1 if (yesvote > novote) & (yespop< nopop)
gen cmn=0
replace cmn=1 if (novote >=yesvote) & (yespop>nopop)
gen cm = cmy+cmn
collapse (mean) cm, by(congress)
merge 1:1 congress using "independent_vars.dta"
drop _merge
sort congress
tset congress 
generate newcm=d.cm
generate newgini=d.gini
generate newclosevote=d.closevote
generate newmajfrac=d.majfrac
gen giniclose=newgini*newclosevote
gen majfracclose=newmajfrac*newclosevote
gen ginimajfrac=newgini*newmajfrac
regress newcm newgini newclosevote newmajfrac giniclose majfracclose
outreg2 using test.doc, dec(2)
regress newcm newgini newclosevote newmajfrac giniclose majfracclose ginimajfrac
outreg2 using test.doc, dec(2) append
clear
